local hx__chigang = fk.CreateSkill{
  name = "hx__chigang",
  tags = { Skill.Switch, Skill.Compulsory },
}


hx__chigang:addEffect(fk.EventPhaseChanging, {
  anim_type = "switch",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(hx__chigang.name) then
      if data.phase == Player.Judge then
        return player:getSwitchSkillState(self.name, false) == fk.SwitchYang
      elseif data.phase == Player.Discard then
        return player:getSwitchSkillState(self.name, false) ~= fk.SwitchYang
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    if player:getSwitchSkillState(self.name, true) == fk.SwitchYang and data.phase == Player.Judge then
      data.who = player
      data.phase = Player.Draw
    end
    if player:getSwitchSkillState(self.name, true) ~= fk.SwitchYang and data.phase == Player.Discard then
      data.who = player
      data.phase = Player.Play
    end
  end,
})


return hx__chigang
